package com.bbs.web;

import com.bbs.common.vo.DataResult;
import com.bbs.dto.SysUserListDTO;
import com.bbs.dto.SysUserSaveDTO;
import com.bbs.dto.SysUserUpdateDTO;
import com.bbs.service.SysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * SysUserController
 *
 * @author yangjiajia
 * @since 2024/5/20 11:13
 */
@RestController
@RequestMapping("sys/user")
public class SysUserController {

    @Autowired
    private SysUserService sysUserService;

    @PostMapping("list")
    public DataResult list(@RequestBody SysUserListDTO listDTO) {
        return DataResult.success(sysUserService.list(listDTO));
    }

    @PostMapping("save")
    public DataResult save(@RequestBody SysUserSaveDTO saveDTO) {
        sysUserService.save(saveDTO);
        return DataResult.success();
    }

    @PostMapping("update")
    public DataResult update(@RequestBody SysUserUpdateDTO updateDTO) {
        sysUserService.update(updateDTO);
        return DataResult.success();
    }

    @GetMapping("lock")
    public DataResult accountLock(@RequestParam("id") Integer id) {
        sysUserService.accountLock(id);
        return DataResult.success();
    }

    @GetMapping("unlock")
    public DataResult accountUnLock(@RequestParam("id") Integer id) {
        sysUserService.accountUnLock(id);
        return DataResult.success();
    }
}
